const {BrowserWindow, app, Menu} = require('electron')

let win = null;
process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true';


app.on('window-all-closed', () => {
  if (process.platform !== 'drawin') {
    app.quit();
  }
});

app.on('ready', () => {
  Menu.setApplicationMenu(null);
  win = new BrowserWindow({
    width: 1280,
    height: 720,
    webPreferences: {
      nodeIntegration: true,
      contextIsolation: false,  //Electron 12.0以上版本需要的额外设置此项
    },
    show: false
  });
  if (process.env.NODE_ENV === 'development') {
    win.loadURL('http://localhost:8000/');
  } else {
    win.loadFile( `${__dirname}/dist/index.html`);
  }
  win.on('closed', () => {
    win = null;
  });
  win.on('ready-to-show', () => {
    win.show();
  });
});
